package com.jzo2o.customer.controller.operation;

import cn.hutool.core.bean.BeanUtil;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.customer.model.dto.request.CertificationAuditReqDTO;
import com.jzo2o.customer.model.dto.request.WorkerCertificationAuditPageQueryReqDTO;
import com.jzo2o.customer.model.dto.response.WorkerCertificationAuditResDTO;
import com.jzo2o.customer.model.dto.response.WorkerCertificationResDTO;
import com.jzo2o.customer.service.IWorkerCertificationService;
import com.jzo2o.mvc.model.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 服务人员认证信息相关接口
 *
 * @author SCPGHOST
 */
@RestController("operationWorkerCertificationController")
@RequestMapping("/operation")
@Api(tags = "运营端 - 服务人员认证信息相关接口")
public class WorkerCertificationController {

    @Resource
    private IWorkerCertificationService workerCertificationService;

    @GetMapping("/worker-certification/{id}")
    @ApiOperation("根据服务人员id查询认证信息")
    public WorkerCertificationResDTO queryById(@PathVariable("id") Long id) {
        return BeanUtil.toBean(workerCertificationService.getById(id), WorkerCertificationResDTO.class);
    }

    @GetMapping("/worker-certification-audit/page")
    @ApiOperation("审核服务人员认证分页查询")
    public PageResult<WorkerCertificationAuditResDTO> pageQuery(@ModelAttribute WorkerCertificationAuditPageQueryReqDTO workerCertificationAuditPageQueryReqDTO) {
        return workerCertificationService.pageQuery(workerCertificationAuditPageQueryReqDTO);
    }

    @PutMapping ("/worker-certification-audit/audit/{id}")
    @ApiOperation("审核服务人员认证信息")
    public Result<Void> auditWorkerCertification(@PathVariable("id") Long id,@RequestBody CertificationAuditReqDTO certificationAuditReqDTO) {
        workerCertificationService.workerCertificationAudit(id,certificationAuditReqDTO);
        return Result.ok();
    }
}
